package com.dhy.dao;

import com.dhy.dbCore.util.DbUtil;
import com.dhy.dbCore.JdbcTemplateFacade;
import com.dhy.dto.ClassDto;

import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/6/7 11:13
 */
public class ClassDao {

    private JdbcTemplateFacade jt= DbUtil.getJT();

    public List<ClassDto> queryStudByClass(String classId) {
          String sql="SELECT cl.name className,s.sno,s.name,c.name courseName,c.type,cs.score\n" +
                  "FROM class cl\n" +
                  "INNER JOIN stu s\n" +
                  "ON cl.id=s.classId\n" +
                  "INNER JOIN courseSelection cs\n" +
                  "ON s.id=cs.sid AND cs.score<60\n" +
                  "INNER JOIN course c\n" +
                  "ON c.id=cs.cid\n" +
                  "WHERE cl.id='"+classId+"'";
       return jt.list(sql, ClassDto.class);
    }


    public Boolean deleteClass(String cid) {
        String sql="delete from class where id = '"+cid+"';";
        return jt.delete(sql);
    }
}
